class_name VisualInvulnerability
extends Node

@export var resource_node:ResourceNode
@export var animation_player:AnimationPlayer
@export var animation_invulnerable:StringName
@export var animation_normal:StringName

var damage_resource:DamageResource
func _ready()->void:
	damage_resource = resource_node.get_resource("damage")
	assert(damage_resource != null)
	damage_resource.can_receive_changed.connect(_set_invulnerability_animation)
	
	# in case used with PoolNode
	request_ready()

func _set_invulnerability_animation()->void:
	if !damage_resource.can_receive_damage:
		animation_player.play(animation_invulnerable)
	else:
		animation_player.play(animation_normal)
